<center><h2 class="postTitle"><font color = "black">Edytuj problem</font></h2></center>
<br/>

<form action="index.php?location=edytuj_problem&problem_id=<?php echo $_GET['problem_id']; ?>" enctype="multipart/form-data" method="post" ">
<table>

<!-- Zmiana nazwy problemu-->

<tr>
	<td>Nazwa problemu:</td>	<td> <input type="text" size="40" name="problem_name" value="<?php echo get_problem_name($_GET['problem_id']); ?> "/></td>
</tr>

<!-- Zmiana statusu problemu -->

<tr>
	<td> Status problemu: </td> <td>
	<select name="problem_status"" style="width: 220px">
		<?php 
			$currProblemStatus = get_problem_status( $_GET['problem_id'] );
			echo '<option value="'.$currProblemStatus.'">'.$currProblemStatus.'</option>'; 
			  		
			$problemStatus_list = get_possible_status();
			  		
			foreach ($problemStatus_list as $problemStatus){
			  	if ($problemStatus != $currProblemStatus)
			  		echo '<option value="'.$problemStatus.'">'.$problemStatus.'</option>'; 
			 }
		?>
		</select>
	</td>
</tr>

<!-- Zmiana kategorii problemu-->
<tr>
	<td>Nazwa kategorii:</td>	<td>
		<select name="section_id"" style="width: 220px">
			  <?php
			  		$currSectionID = get_problem_section_id( $_GET['problem_id'] );
			  		
			  		echo '<option value="'.$currSectionID.'">'.get_section_name($currSectionID).'</option>'; 
			  		
			  		$section_list = get_all_sections();
      		
			      		foreach ($section_list as $section){
			      			echo '<option value="'.get_sectionID($section[0]).'">'. normalize($section[0], $section[1]) .'</option>'; 
			     		}
			  ?>
		</select>
	</td>
</tr>

<!-- Zmiana odpowiedzialnego-->
<tr>
	<td>Odpowiedzialny:</td>	<td>
		<select name="owner_name"" style="width: 100px">
			  <?php
			  		$currOwner = get_problem_owner( $_GET['problem_id'] );
			  		
			  		echo '<option value="'.$currOwner.'">'.$currOwner.'</option>'; 
			  		
			  		$owner_list = get_all_owners();
      		
			      		foreach ($owner_list as $owner){
			      			if ($owner != $currOwner)
			      				echo '<option value="'.$owner.'">'. $owner .'</option>'; 
			     		}
			  ?>
		</select>
	</td>
</tr>
</table>

<br/>
Opis problemu:<br><textarea name="problem_description" cols="46" rows="15"><?php echo get_problem_description($_GET['problem_id']); ?> </textarea> <br>
<br/>
Main programu:<br><textarea name="main" cols="46" rows="15"><?php echo get_problem_main($_GET['problem_id']); ?> </textarea> <br>

<br/>
<label for="file1">Plik zawierający dane wejściowe:</label>
<input type="file" name="file1" id="file1" /> <br>

<label for="file2">Plik zawierający oczekiwany out:</label>
<input type="file" name="file2" id="file2" /> <br>

<br/>
<center><input align="right" type="submit" value="Zmień"/></center>
</form>

<br/>
<h2 class="postTitle"><font color = "black">Dodaj komentarz</font></h2>

<form action="index.php?location=edytuj_problem&problem_id=<?php echo $_GET['problem_id']; ?>" method="post" ">

<br><textarea name="comment_content" cols="46" rows="15">Twój komentarz... </textarea> <br>
<input align="right" type="submit" value="Dodaj komentarz!"/>

</form>

<br/>
<hr size="5" color="black" width="700" />
<br/>
<h2> Dotychczasowe komentarze: </h2>
<?php
	$array_of_comments = get_array_of_comments($_GET['problem_id']);
	
	if (count($array_of_comments) == 0){
		echo '<p> Brak komentarzy </p><br>';
	}
	else{
		foreach ($array_of_comments as $comment){
			$nazwa_uzytkownika = $comment[0];
			$data_dodania = $comment[1];
			$wiadomosc = $comment[2];	
			echo "<p>Dodane przez <b>$nazwa_uzytkownika</b> w dniu <b>$data_dodania</b>.</p><br>";
			echo '<textarea name="nazwa" cols="46" rows="7" readonly="readonly">';
			echo $wiadomosc;
			echo "</textarea>"; 
			echo '<hr width="555" />';
		}
	}
?>

